{extend name="../../admin/view/main"}

{block name="button"}
<!--{if auth("add")}-->
<button data-open="{:url('add')}" class='layui-btn layui-btn-sm layui-btn-primary'>添加规则</button>
<!--{/if}-->

<!--{if auth("remove")}-->
<button data-action='{:url("remove")}' data-rule="id#{key}" data-csrf="{:systoken('remove')}" data-confirm="确定要删除这些规则吗？" class='layui-btn layui-btn-sm layui-btn-primary'>删除规则</button>
<!--{/if}-->
{/block}

{block name='content'}
<div class="think-box-notify">
    特别注意：关注自动回复使用微信客服消息接口发送，因此多图文只能发送每组图文的第一篇文章，另外还需要开启系统任务功能。
</div>

<div class="think-box-shadow">
    {include file='auto/index_search'}
    <table class="layui-table" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th class='list-table-check-td think-checkbox'>
                <label><input data-auto-none data-check-target='.list-check-box' type='checkbox'></label>
            </th>
            <th class="text-left nowrap">消息编号</th>
            <th class="text-left nowrap">延迟时间</th>
            <th class="text-center nowrap">消息类型</th>
            <th class="text-center nowrap">预览</th>
            <th class="text-left nowrap">添加时间</th>
            <th class="text-left nowrap">状态</th>
            <th></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='list-table-check-td think-checkbox'>
                <label><input class="list-check-box" value='{$vo.id}' type='checkbox'></label>
            </td>
            <td class="text-left nowrap">{$vo.code}</td>
            <td class="text-left nowrap">{$vo.time}</td>
            <td class="text-center nowrap">{$vo.type}</td>
            <td class="text-center nowrap notselect">
                {if $vo.type eq '音乐'}
                <a data-phone-view='{:url("@wechat/api.view/music")}?title={$vo.music_title|urlencode}&desc={$vo.music_desc|urlencode}'>预览</a>
                {elseif in_array($vo.type,['文字','转客服'])}
                <a data-phone-view='{:url("@wechat/api.view/text")}?content={$vo.content|urlencode}'>预览</a>
                {elseif $vo.type eq '图片'}
                <a data-phone-view='{:url("@wechat/api.view/image")}?content={$vo.image_url|urlencode}'>预览</a>
                {elseif $vo.type eq '图文'}
                <a data-phone-view='{:url("@wechat/api.view/news")}?id={$vo.news_id}'>预览</a>
                {elseif $vo.type eq '视频'}
                <a data-phone-view='{:url("@wechat/api.view/video")}?title={$vo.video_title|urlencode}&desc={$vo.video_desc|urlencode}&url={$vo.video_url|urlencode}'>预览</a>
                {elseif $vo.type eq '语音'}
                <a data-phone-view='{:url("@wechat/api.view/voice")}?content={$vo.voice_url|urlencode}'>预览</a>
                {else} {$vo.content} {/if}
            </td>
            <td class="text-left nowrap">{$vo.create_at|format_datetime}</td>
            <td class='text-left nowrap'>{if $vo.status eq 0}<span class="color-red">已禁用</span>{elseif $vo.status eq 1}<span class="color-green">已激活</span>{/if}</td>
            <td class='text-left nowrap'>

                <!--{if auth("edit")}-->
                <a class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
                <!--{/if}-->

                <!--{if auth("state") and $vo.status eq 1}-->
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#0" data-csrf="{:systoken('state')}">禁 用</a>
                <!--{elseif auth("state") and $vo.status eq 0}-->
                <a class="layui-btn layui-btn-sm layui-btn-warm" data-action="{:url('state')}" data-value="id#{$vo.id};status#1" data-csrf="{:systoken('state')}">激 活</a>
                <!--{/if}-->

                <!--{if auth("remove")}-->
                <a class="layui-btn layui-btn-sm layui-btn-danger" data-confirm="确定要删除该规则吗？" data-action="{:url('remove')}" data-value="id#{$vo.id}" data-csrf="{:systoken('remove')}">删 除</a>
                <!--{/if}-->

            </td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}